<?php
	
	namespace Aspic\Form\Element;
	use Aspic\Security\Security as S;
	
	/**
	* AutoComplete form element
	*/
	class AutoComplete extends TextBox {
		protected $_autoCompleteOptions;
		
		public function __construct($name, $label = '', array $autoCompleteOptions = array(), array $attributes = array()) {
			parent::__construct($name, $label, null, $attributes);
			
			$this->opt('autoCompleteOptions', ($autoCompleteOptions));
		}

		public function outJs() {
			$acOptions = $this->opt('autoCompleteOptions');
			
			return '
			$(function() {
			$("#'.$this->attr('id').'").autocomplete('.json_encode($acOptions).');
			});
			';
		}
		
	}	
	
?>